home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kparts / browserextension.h next >
Encoding:
C/C++ Source or Header  |  2006-10-01  |  27.6 KB  |  833 lines

  1. /* This file is part of the KDE project
  2.    Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
  3.                       David Faure <faure@kde.org>
  4.  
  5.    This library is free software; you can redistribute it and/or
  6.    modify it under the terms of the GNU Library General Public
  7.    License as published by the Free Software Foundation; either
  8.    version 2 of the License, or (at your option) any later version.
  9.  
  10.    This library is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    Library General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU Library General Public License
  16.    along with this library; see the file COPYING.LIB.  If not, write to
  17.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.    Boston, MA 02110-1301, USA.
  19. */
  20.  
  21. #ifndef __kparts_browserextension_h__
  22. #define __kparts_browserextension_h__
  23.  
  24. #include <sys/types.h>
  25.  
  26. #include <qpoint.h>
  27. #include <qptrlist.h>
  28. #include <qdatastream.h>
  29. #include <qstringlist.h>
  30. #include <qpair.h>
  31.  
  32. #include <kparts/part.h>
  33. #include <kparts/event.h>
  34.  
  35. class KFileItem;
  36. typedef QPtrList<KFileItem> KFileItemList;
  37. class QString;
  38.  
  39. namespace KParts {
  40.  
  41. class BrowserInterface;
  42.  
  43. struct URLArgsPrivate;
  44.  
  45. /**
  46.  * URLArgs is a set of arguments bundled into a structure,
  47.  * to allow specifying how a URL should be opened by openURL().
  48.  * In other words, this is like arguments to openURL(), but without
  49.  * have to change the signature of openURL() (since openURL is a
  50.  * generic KParts method).
  51.  * The parts (with a browser extension) who care about urlargs will
  52.  * use those arguments, others will ignore them.
  53.  *
  54.  * This can also be used the other way round, when a part asks
  55.  * for a URL to be opened (with openURLRequest or createNewWindow).
  56.  */
  57. struct KPARTS_EXPORT URLArgs
  58. {
  59.   URLArgs();
  60.   URLArgs( const URLArgs &args );
  61.   URLArgs &operator=( const URLArgs &args);
  62.  
  63.   URLArgs( bool reload, int xOffset, int yOffset, const QString &serviceType = QString::null );
  64.   virtual ~URLArgs();
  65.  
  66.   /**
  67.    * This buffer can be used by the part to save and restore its contents.
  68.    * See KHTMLPart for instance.
  69.    */
  70.   QStringList docState;
  71.  
  72.   /**
  73.    * @p reload is set when the cache shouldn't be used (forced reload).
  74.    */
  75.   bool reload;
  76.   /**
  77.    * @p xOffset is the horizontal scrolling of the part's widget
  78.    * (in case it's a scrollview). This is saved into the history
  79.    * and restored when going back in the history.
  80.    */
  81.   int xOffset;
  82.   /**
  83.    * @p yOffset vertical scrolling position, xOffset.
  84.    */
  85.   int yOffset;
  86.   /**
  87.    * The servicetype (usually mimetype) to use when opening the next URL.
  88.    */
  89.   QString serviceType;
  90.  
  91.   /**
  92.    * KHTML-specific field, contents of the HTTP POST data.
  93.    */
  94.   QByteArray postData;
  95.  
  96.   /**
  97.    * KHTML-specific field, header defining the type of the POST data.
  98.    */
  99.   void setContentType( const QString & contentType );
  100.   /**
  101.    * KHTML-specific field, header defining the type of the POST data.
  102.    */
  103.   QString contentType() const;
  104.   /**
  105.    * KHTML-specific field, whether to do a POST instead of a GET,
  106.    * for the next openURL.
  107.    */
  108.   void setDoPost( bool enable );
  109.  
  110.   /**
  111.    * KHTML-specific field, whether to do a POST instead of a GET,
  112.    * for the next openURL.
  113.    */
  114.   bool doPost() const;
  115.  
  116.   /**
  117.    * Whether to lock the history when opening the next URL.
  118.    * This is used during e.g. a redirection, to avoid a new entry
  119.    * in the history.
  120.    */
  121.   void setLockHistory( bool lock );
  122.   bool lockHistory() const;
  123.  
  124.   /**
  125.    * Whether the URL should be opened in a new tab instead in a new window.
  126.    */
  127.   void setNewTab( bool newTab );
  128.   bool newTab() const;
  129.  
  130.   /**
  131.    * Meta-data to associate with the next KIO operation
  132.    * @see KIO::TransferJob etc.
  133.    */
  134.   QMap<QString, QString> &metaData();
  135.  
  136.   /**
  137.    * The frame in which to open the URL. KHTML/Konqueror-specific.
  138.    */
  139.   QString frameName;
  140.  
  141.   /**
  142.    * If true, the part who asks for a URL to be opened can be 'trusted'
  143.    * to execute applications. For instance, the directory views can be
  144.    * 'trusted' whereas HTML pages are not trusted in that respect.
  145.    */
  146.   bool trustedSource;
  147.  
  148.   /**
  149.    * @return true if the request was a result of a META refresh/redirect request or
  150.    * HTTP redirect.
  151.    */
  152.   bool redirectedRequest () const;
  153.  
  154.   /**
  155.    * Set the redirect flag to indicate URL is a result of either a META redirect
  156.    * or HTTP redirect.
  157.    *
  158.    * @param redirected
  159.    */
  160.   void setRedirectedRequest(bool redirected);
  161.  
  162.   /**
  163.    * Set whether the URL specifies to be opened in a new window
  164.    * @since 3.4
  165.    */
  166.   void setForcesNewWindow( bool forcesNewWindow );
  167.  
  168.   /**
  169.    * Whether the URL specifies to be opened in a new window
  170.    * @since 3.4
  171.    */
  172.   bool forcesNewWindow() const;
  173.  
  174.   URLArgsPrivate *d;
  175. };
  176.  
  177. struct WindowArgsPrivate;
  178.  
  179. /**
  180.  * The WindowArgs are used to specify arguments to the "create new window"
  181.  * call (see the createNewWindow variant that uses WindowArgs).
  182.  * The primary reason for this is the javascript window.open function.
  183.  */
  184. struct KPARTS_EXPORT WindowArgs
  185. {
  186.     WindowArgs();
  187.     ~WindowArgs();
  188.     WindowArgs( const WindowArgs &args );
  189.     WindowArgs &operator=( const WindowArgs &args );
  190.     WindowArgs( const QRect &_geometry, bool _fullscreen, bool _menuBarVisible,
  191.                 bool _toolBarsVisible, bool _statusBarVisible, bool _resizable );
  192.     WindowArgs( int _x, int _y, int _width, int _height, bool _fullscreen,
  193.                 bool _menuBarVisible, bool _toolBarsVisible,
  194.                 bool _statusBarVisible, bool _resizable );
  195.  
  196.     // Position
  197.     int x;
  198.     int y;
  199.     // Size
  200.     int width;
  201.     int height;
  202.     bool fullscreen; //defaults to false
  203.     bool menuBarVisible; //defaults to true
  204.     bool toolBarsVisible; //defaults to true
  205.     bool statusBarVisible; //defaults to true
  206.     bool resizable; //defaults to true
  207.  
  208.     bool lowerWindow; //defaults to false
  209.     bool scrollBarsVisible; //defaults to true
  210.  
  211.     WindowArgsPrivate *d; // don't use before KDE4, many KDE-3.x didn't have an explicit destructor
  212. };
  213.  
  214. /**
  215.  * The KParts::OpenURLEvent event informs that a given part has opened a given URL.
  216.  * Applications can use this event to send this information to interested plugins.
  217.  *
  218.  * The event should be sent before opening the URL in the part, so that the plugins
  219.  * can use part()->url() to get the old URL.
  220.  */
  221. class KPARTS_EXPORT OpenURLEvent : public Event
  222. {
  223. public:
  224.   OpenURLEvent( ReadOnlyPart *part, const KURL &url, const URLArgs &args = URLArgs() );
  225.   virtual ~OpenURLEvent();
  226.  
  227.   ReadOnlyPart *part() const { return m_part; }
  228.   KURL url() const { return m_url; }
  229.   URLArgs args() const { return m_args; }
  230.  
  231.   static bool test( const QEvent *event ) { return Event::test( event, s_strOpenURLEvent ); }
  232.  
  233. private:
  234.   static const char *s_strOpenURLEvent;
  235.   ReadOnlyPart *m_part;
  236.   KURL m_url;
  237.   URLArgs m_args;
  238.  
  239.   class OpenURLEventPrivate;
  240.   OpenURLEventPrivate *d;
  241. };
  242.  
  243. class BrowserExtensionPrivate;
  244.  
  245.  /**
  246.   * The Browser Extension is an extension (yes, no kidding) to
  247.   * KParts::ReadOnlyPart, which allows a better integration of parts
  248.   * with browsers (in particular Konqueror).
  249.   * Remember that ReadOnlyPart only has openURL(KURL), with no other settings.
  250.   * For full-fledged browsing, we need much more than that, including
  251.   * many arguments about how to open this URL (see URLArgs), allowing
  252.   * parts to save and restore their data into the back/forward history,
  253.   * allowing parts to control the location bar URL, to requests URLs
  254.   * to be opened by the hosting browser, etc.
  255.   *
  256.   * The part developer needs to define its own class derived from BrowserExtension,
  257.   * to implement the virtual methods [and the standard-actions slots, see below].
  258.   *
  259.   * The way to associate the BrowserExtension with the part is to simply
  260.   * create the BrowserExtension as a child of the part (in QObject's terms).
  261.   * The hosting application will look for it automatically.
  262.   *
  263.   * Another aspect of the browser integration is that a set of standard
  264.   * actions are provided by the browser, but implemented by the part
  265.   * (for the actions it supports).
  266.   *
  267.   * The following standard actions are defined by the host of the view :
  268.   *
  269.   * [selection-dependent actions]
  270.   * @li @p cut : Copy selected items to clipboard and store 'not cut' in clipboard.
  271.   * @li @p copy : Copy selected items to clipboard and store 'cut' in clipboard.
  272.   * @li @p paste : Paste clipboard into view URL.
  273.   * @li @p pasteTo(const KURL &) : Paste clipboard into given URL.
  274.   * @li @p rename : Rename item in place.
  275.   * @li @p trash : Move selected items to trash.
  276.   * @li @p del : Delete selected items (couldn't call it delete!).
  277.   * @li @p shred : Shred selected items (secure deletion) - DEPRECATED.
  278.   * @li @p properties : Show file/document properties.
  279.   * @li @p editMimeType : show file/document's mimetype properties.
  280.   * @li @p searchProvider : Lookup selected text at default search provider
  281.   *
  282.   * [normal actions]
  283.   * @li @p print : Print :-)
  284.   * @li @p reparseConfiguration : Re-read configuration and apply it.
  285.   * @li @p refreshMimeTypes : If the view uses mimetypes it should re-determine them.
  286.   *
  287.   *
  288.   * The view defines a slot with the name of the action in order to implement the action.
  289.   * The browser will detect the slot automatically and connect its action to it when
  290.   * appropriate (i.e. when the view is active).
  291.   *
  292.   *
  293.   * The selection-dependent actions are disabled by default and the view should
  294.   * enable them when the selection changes, emitting enableAction().
  295.   *
  296.   * The normal actions do not depend on the selection.
  297.   * You need to enable 'print' when printing is possible - you can even do that
  298.   * in the constructor.
  299.   *
  300.   * A special case is the configuration slots, not connected to any action directly,
  301.   * and having parameters.
  302.   *
  303.   * [configuration slot]
  304.   * @li @p setSaveViewPropertiesLocally( bool ): If @p true, view properties are saved into .directory
  305.   *                                       otherwise, they are saved globally.
  306.   * @li @p disableScrolling: no scrollbars
  307.   */
  308. class KPARTS_EXPORT BrowserExtension : public QObject
  309. {
  310.   Q_OBJECT
  311.   Q_PROPERTY( bool urlDropHandling READ isURLDropHandlingEnabled WRITE setURLDropHandlingEnabled )
  312. public:
  313.   /**
  314.    * Constructor
  315.    *
  316.    * @param parent The KParts::ReadOnlyPart that this extension ... "extends" :)
  317.    * @param name An optional name for the extension.
  318.    */
  319.   BrowserExtension( KParts::ReadOnlyPart *parent,
  320.                     const char *name = 0L );
  321.  
  322.  
  323.   virtual ~BrowserExtension();
  324.  
  325.   typedef uint PopupFlags;
  326.  
  327.   /**
  328.    * Set of flags passed via the popupMenu signal, to ask for some items in the popup menu.
  329.    * DefaultPopupItems: default value, no additional menu item
  330.    * ShowNavigationItems: show "back" and "forward" (usually done when clicking the background of the view, but not an item)
  331.    * ShowUp: show "up" (same thing, but not over e.g. HTTP). Requires ShowNavigationItems.
  332.    * ShowReload: show "reload" (usually done when clicking the background of the view, but not an item)
  333.    * ShowBookmark: show "add to bookmarks" (usually not done on the local filesystem)
  334.    * ShowCreateDirectory: show "create directory" (usually only done on the background of the view, or
  335.    *                      in hierarchical views like directory trees, where the new dir would be visible)
  336.    * ShowTextSelectionItems: set when selecting text, for a popup that only contains text-related items.
  337.    * NoDeletion: deletion, trashing and renaming not allowed (e.g. parent dir not writeable).
  338.    *            (this is only needed if the protocol itself supports deletion, unlike e.g. HTTP)
  339.    *
  340.    * KDE4 TODO: add IsLink flag, for "Bookmark This Link" and linkactions merging group.
  341.    *                    [currently it depends on which signal is emitted]
  342.    *            add ShowURLOperation flags for copy,cut,paste,rename,trash,del [same thing]
  343.    */
  344.   enum { DefaultPopupItems=0x0000, ShowNavigationItems=0x0001,
  345.          ShowUp=0x0002, ShowReload=0x0004, ShowBookmark=0x0008,
  346.          ShowCreateDirectory=0x0010, ShowTextSelectionItems=0x0020,
  347.          NoDeletion=0x0040 ///< @since 3.4
  348.        };
  349.  
  350.  
  351.   /**
  352.    * Set the parameters to use for opening the next URL.
  353.    * This is called by the "hosting" application, to pass parameters to the part.
  354.    * @see URLArgs
  355.    */
  356.   virtual void setURLArgs( const URLArgs &args );
  357.  
  358.   /**
  359.    * Retrieve the set of parameters to use for opening the URL
  360.    * (this must be called from openURL() in the part).
  361.    * @see URLArgs
  362.    */
  363.   URLArgs urlArgs() const;
  364.  
  365.   /**
  366.    * Returns the current x offset.
  367.    *
  368.    * For a scrollview, implement this using contentsX().
  369.    */
  370.   virtual int xOffset();
  371.   /**
  372.    * Returns the current y offset.
  373.    *
  374.    * For a scrollview, implement this using contentsY().
  375.    */
  376.   virtual int yOffset();
  377.  
  378.   /**
  379.    * Used by the browser to save the current state of the view
  380.    * (in order to restore it if going back in navigation).
  381.    *
  382.    * If you want to save additional properties, reimplement it
  383.    * but don't forget to call the parent method (probably first).
  384.    */
  385.   virtual void saveState( QDataStream &stream );
  386.  
  387.   /**
  388.    * Used by the browser to restore the view in the state
  389.    * it was when we left it.
  390.    *
  391.    * If you saved additional properties, reimplement it
  392.    * but don't forget to call the parent method (probably first).
  393.    */
  394.   virtual void restoreState( QDataStream &stream );
  395.  
  396.   /**
  397.    * Returns whether url drop handling is enabled.
  398.    * See setURLDropHandlingEnabled for more information about this
  399.    * property.
  400.    */
  401.   bool isURLDropHandlingEnabled() const;
  402.  
  403.   /**
  404.    * Enables or disables url drop handling. URL drop handling is a property
  405.    * describing whether the hosting shell component is allowed to install an
  406.    * event filter on the part's widget, to listen for URI drop events.
  407.    * Set it to true if you are exporting a BrowserExtension implementation and
  408.    * do not provide any special URI drop handling. If set to false you can be
  409.    * sure to receive all those URI drop events unfiltered. Also note that the
  410.    * implementation as of Konqueror installs the event filter only on the part's
  411.    * widget itself, not on child widgets.
  412.    */
  413.   void setURLDropHandlingEnabled( bool enable );
  414.  
  415.   void setBrowserInterface( BrowserInterface *impl );
  416.   BrowserInterface *browserInterface() const;
  417.  
  418.   /**
  419.    * @return the status (enabled/disabled) of an action.
  420.    * When the enableAction signal is emitted, the browserextension
  421.    * stores the status of the action internally, so that it's possible
  422.    * to query later for the status of the action, using this method.
  423.    */
  424.   bool isActionEnabled( const char * name ) const;
  425.  
  426.   /**
  427.    * @return the text of an action, if it was set explicitely by the part.
  428.    * When the setActionText signal is emitted, the browserextension
  429.    * stores the text of the action internally, so that it's possible
  430.    * to query later for the text of the action, using this method.
  431.    * @since 3.5
  432.    */
  433.   QString actionText( const char * name ) const;
  434.  
  435.   typedef QMap<QCString,QCString> ActionSlotMap;
  436.   /**
  437.    * Returns a map containing the action names as keys and corresponding
  438.    * SLOT()'ified method names as data entries.
  439.    *
  440.    * This is very useful for
  441.    * the host component, when connecting the own signals with the
  442.    * extension's slots.
  443.    * Basically you iterate over the map, check if the extension implements
  444.    * the slot and connect to the slot using the data value of your map
  445.    * iterator.
  446.    * Checking if the extension implements a certain slot can be done like this:
  447.    *
  448.    * \code
  449.    *   extension->metaObject()->slotNames().contains( actionName + "()" )
  450.    * \endcode
  451.    *
  452.    * (note that @p actionName is the iterator's key value if already
  453.    *  iterating over the action slot map, returned by this method)
  454.    *
  455.    * Connecting to the slot can be done like this:
  456.    *
  457.    * \code
  458.    *   connect( yourObject, SIGNAL( yourSignal() ),
  459.    *            extension, mapIterator.data() )
  460.    * \endcode
  461.    *
  462.    * (where "mapIterator" is your QMap<QCString,QCString> iterator)
  463.    */
  464.   static ActionSlotMap actionSlotMap();
  465.  
  466.   /**
  467.    * @return a pointer to the static action-slot map. Preferred method to get it.
  468.    * The map is created if it doesn't exist yet
  469.    */
  470.   static ActionSlotMap * actionSlotMapPtr();
  471.  
  472.   /**
  473.    * Queries @p obj for a child object which inherits from this
  474.    * BrowserExtension class. Convenience method.
  475.    */
  476.   static BrowserExtension *childObject( QObject *obj );
  477.  
  478.   /**
  479.    * Asks the hosting browser to perform a paste (using openURLRequestDelayed)
  480.    * @since 3.2
  481.    */
  482.   void pasteRequest();
  483.  
  484. // KDE invents support for public signals...
  485. #undef signals
  486. #define signals public
  487. signals:
  488. #undef signals
  489. #define signals protected
  490.   /**
  491.    * Enables or disable a standard action held by the browser.
  492.    *
  493.    * See class documentation for the list of standard actions.
  494.    */
  495.   void enableAction( const char * name, bool enabled );
  496.  
  497.   /**
  498.    * Change the text of a standard action held by the browser.
  499.    * This can be used to change "Paste" into "Paste Image" for instance.
  500.    *
  501.    * See class documentation for the list of standard actions.
  502.    * @since 3.5
  503.    */
  504.   void setActionText( const char * name, const QString& text );
  505.  
  506.   /**
  507.    * Asks the host (browser) to open @p url.
  508.    * To set a reload, the x and y offsets, the service type etc., fill in the
  509.    * appropriate fields in the @p args structure.
  510.    * Hosts should not connect to this signal but to openURLRequestDelayed.
  511.    */
  512.   void openURLRequest( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
  513.  
  514.   /**
  515.    * This signal is emitted when openURLRequest is called, after a 0-seconds timer.
  516.    * This allows the caller to terminate what it's doing first, before (usually)
  517.    * being destroyed. Parts should never use this signal, hosts should only connect
  518.    * to this signal.
  519.    */
  520.   void openURLRequestDelayed( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
  521.  
  522.   /**
  523.    * Tells the hosting browser that the part opened a new URL (which can be
  524.    * queried via KParts::Part::url().
  525.    *
  526.    * This helps the browser to update/create an entry in the history.
  527.    * The part may @em not emit this signal together with openURLRequest().
  528.    * Emit openURLRequest() if you want the browser to handle a URL the user
  529.    * asked to open (from within your part/document). This signal however is
  530.    * useful if you want to handle URLs all yourself internally, while still
  531.    * telling the hosting browser about new opened URLs, in order to provide
  532.    * a proper history functionality to the user.
  533.    * An example of usage is a html rendering component which wants to emit
  534.    * this signal when a child frame document changed its URL.
  535.    * Conclusion: you probably want to use openURLRequest() instead.
  536.    */
  537.   void openURLNotify();
  538.  
  539.   /**
  540.    * Updates the URL shown in the browser's location bar to @p url.
  541.    */
  542.   void setLocationBarURL( const QString &url );
  543.  
  544.   /**
  545.    * Sets the URL of an icon for the currently displayed page.
  546.    */
  547.   void setIconURL( const KURL &url );
  548.  
  549.   /**
  550.    * Asks the hosting browser to open a new window for the given @p url.
  551.    *
  552.    * The @p args argument is optional additional information for the
  553.    * browser,
  554.    * @see KParts::URLArgs
  555.    */
  556.   void createNewWindow( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
  557.  
  558.   /**
  559.    * Asks the hosting browser to open a new window for the given @p url
  560.    * and return a reference to the content part.
  561.    * The request for a reference to the part is only fullfilled/processed
  562.    * if the serviceType is set in the @p args . (otherwise the request cannot be
  563.    * processed synchroniously.
  564.    */
  565.   void createNewWindow( const KURL &url, const KParts::URLArgs &args,
  566.                         const KParts::WindowArgs &windowArgs, KParts::ReadOnlyPart *&part );
  567.  
  568.   /**
  569.    * Since the part emits the jobid in the started() signal,
  570.    * progress information is automatically displayed.
  571.    *
  572.    * However, if you don't use a KIO::Job in the part,
  573.    * you can use loadingProgress() and speedProgress()
  574.    * to display progress information.
  575.    */
  576.   void loadingProgress( int percent );
  577.   /**
  578.    * @see loadingProgress
  579.    */
  580.   void speedProgress( int bytesPerSecond );
  581.  
  582.   void infoMessage( const QString & );
  583.  
  584.   /**
  585.    * Emit this to make the browser show a standard popup menu
  586.    * at the point @p global for the files @p items.
  587.    */
  588.   void popupMenu( const QPoint &global, const KFileItemList &items );
  589.  
  590.   /**
  591.    * Emit this to make the browser show a standard popup menu
  592.    * at the point @p global for the files @p items.
  593.    *
  594.    * The GUI described by @p client is being merged with the popupmenu of the host
  595.    */
  596.   void popupMenu( KXMLGUIClient *client, const QPoint &global, const KFileItemList &items );
  597.  
  598.   void popupMenu( KXMLGUIClient *client, const QPoint &global, const KFileItemList &items, const KParts::URLArgs &args, KParts::BrowserExtension::PopupFlags i );
  599.  
  600.   /**
  601.    * Emit this to make the browser show a standard popup menu
  602.    * at the point @p global for the given @p url.
  603.    *
  604.    * Give as much information
  605.    * about this URL as possible, like the @p mimeType and the file type
  606.    * (@p mode: S_IFREG, S_IFDIR...)
  607.    */
  608.   void popupMenu( const QPoint &global, const KURL &url,
  609.                   const QString &mimeType, mode_t mode = (mode_t)-1 );
  610.  
  611.   /**
  612.    * Emit this to make the browser show a standard popup menu
  613.    * at the point @p global for the given @p url.
  614.    *
  615.    * Give as much information
  616.    * about this URL as possible, like the @p mimeType and the file type
  617.    * (@p mode: S_IFREG, S_IFDIR...)
  618.    * The GUI described by @p client is being merged with the popupmenu of the host
  619.    */
  620.   void popupMenu( KXMLGUIClient *client,
  621.                   const QPoint &global, const KURL &url,
  622.                   const QString &mimeType, mode_t mode = (mode_t)-1 );
  623.  
  624.   /**
  625.    * Emit this to make the browser show a standard popup menu
  626.    * at the point @p global for the given @p url.
  627.    *
  628.    * Give as much information
  629.    * about this URL as possible, like @p args.mimeType and the file type
  630.    * (@p mode: S_IFREG, S_IFDIR...)
  631.    * The GUI described by @p client is being merged with the popupmenu of the host
  632.    */
  633.   void popupMenu( KXMLGUIClient *client,
  634.                   const QPoint &global, const KURL &url,
  635.                   const KParts::URLArgs &args, KParts::BrowserExtension::PopupFlags i, mode_t mode = (mode_t)-1 );
  636.  
  637.   /**
  638.    * Inform the hosting application about the current selection.
  639.    * Used when a set of files/URLs is selected (with full information
  640.    * about those URLs, including size, permissions etc.)
  641.    */
  642.   void selectionInfo( const KFileItemList &items );
  643.   /**
  644.    * Inform the hosting application about the current selection.
  645.    * Used when some text is selected.
  646.    */
  647.   void selectionInfo( const QString &text );
  648.   /**
  649.    * Inform the hosting application about the current selection.
  650.    * Used when a set of URLs is selected.
  651.    */
  652.   void selectionInfo( const KURL::List &urls );
  653.  
  654.   /**
  655.    * Inform the hosting application that the user moved the mouse over an item.
  656.    * Used when the mouse is on an URL.
  657.    */
  658.   void mouseOverInfo( const KFileItem* item );
  659.  
  660.   /**
  661.    * Ask the hosting application to add a new HTML (aka Mozilla/Netscape)
  662.    * SideBar entry.
  663.    */
  664.   void addWebSideBar(const KURL &url, const QString& name);
  665.  
  666.   /**
  667.    * Ask the hosting application to move the top level widget.
  668.    */
  669.   void moveTopLevelWidget( int x, int y );
  670.  
  671.   /**
  672.    * Ask the hosting application to resize the top level widget.
  673.    */
  674.   void resizeTopLevelWidget( int w, int h );
  675.  
  676.   /**
  677.    * Ask the hosting application to focus @p part.
  678.    * @since 3.4
  679.    */
  680.   void requestFocus(KParts::ReadOnlyPart *part);
  681.  
  682.   /**
  683.    * Tell the host (browser) about security state of current page
  684.    * enum PageSecurity { NotCrypted, Encrypted, Mixed };
  685.    * @since 3.4
  686.    */
  687.   void setPageSecurity( int );
  688.  
  689. #define KPARTS_BROWSEREXTENSION_HAS_ITEMS_REMOVED
  690.   /**
  691.    * Inform the host about items that have been removed.
  692.    * @since 3.5.5
  693.    */
  694.   void itemsRemoved( const KFileItemList &items );
  695.  
  696. private slots:
  697.   void slotCompleted();
  698.   void slotOpenURLRequest( const KURL &url, const KParts::URLArgs &args );
  699.   void slotEmitOpenURLRequestDelayed();
  700.   void slotEnableAction( const char *, bool );
  701.   void slotSetActionText( const char*, const QString& );
  702.  
  703. private:
  704.   KParts::ReadOnlyPart *m_part;
  705.   URLArgs m_args;
  706. public:
  707.   typedef QMap<QCString,int> ActionNumberMap;
  708.  
  709. private:
  710.   static ActionNumberMap * s_actionNumberMap;
  711.   static ActionSlotMap * s_actionSlotMap;
  712.   static void createActionSlotMap();
  713. protected:
  714.   virtual void virtual_hook( int id, void* data );
  715. private:
  716.   BrowserExtensionPrivate *d;
  717. };
  718.  
  719. /**
  720.  * An extension class for container parts, i.e. parts that contain
  721.  * other parts.
  722.  * For instance a KHTMLPart hosts one part per frame.
  723.  */
  724. class KPARTS_EXPORT BrowserHostExtension : public QObject
  725. {
  726.   Q_OBJECT
  727. public:
  728.   BrowserHostExtension( KParts::ReadOnlyPart *parent,
  729.                         const char *name = 0L );
  730.  
  731.   virtual ~BrowserHostExtension();
  732.  
  733.   /**
  734.    * Returns a list of the names of all hosted child objects.
  735.    *
  736.    * Note that this method does not query the child objects recursively.
  737.    */
  738.   virtual QStringList frameNames() const;
  739.  
  740.   /**
  741.    * Returns a list of pointers to all hosted child objects.
  742.    *
  743.    * Note that this method does not query the child objects recursively.
  744.    */
  745.   virtual const QPtrList<KParts::ReadOnlyPart> frames() const;
  746.  
  747.   /**
  748.    * Returns the part that contains @p frame and that may be accessed
  749.    * by @p callingPart
  750.    * @since 3.3
  751.    */
  752.   BrowserHostExtension *findFrameParent(KParts::ReadOnlyPart *callingPart, const QString &frame);
  753.  
  754.   /**
  755.    * Opens the given url in a hosted child frame. The frame name is specified in the
  756.    * frameName variable in the urlArgs argument structure (see KParts::URLArgs ) .
  757.    */
  758.   virtual bool openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs );
  759.  
  760.   /**
  761.    * Queries @p obj for a child object which inherits from this
  762.    * BrowserHostExtension class. Convenience method.
  763.    */
  764.   static BrowserHostExtension *childObject( QObject *obj );
  765.  
  766. protected:
  767.   /** This 'enum' along with the structure below is NOT part of the public API.
  768.    * It's going to disappear in KDE 4.0 and is likely to change inbetween.
  769.    *
  770.    * @internal
  771.    */
  772.   enum { VIRTUAL_FIND_FRAME_PARENT = 0x10 };
  773.   struct FindFrameParentParams
  774.   {
  775.       BrowserHostExtension *parent;
  776.       KParts::ReadOnlyPart *callingPart;
  777.       QString frame;
  778.   };
  779.  
  780.   virtual void virtual_hook( int id, void* data );
  781. private:
  782.   class BrowserHostExtensionPrivate;
  783.   BrowserHostExtensionPrivate *d;
  784. };
  785.  
  786. /**
  787.  * An extension class for LiveConnect, i.e\. a call from JavaScript
  788.  * from a HTML page which embeds this part.
  789.  * A part can have an object hierarchie by using objid as a reference
  790.  * to an object.
  791.  */
  792. class KPARTS_EXPORT LiveConnectExtension : public QObject
  793. {
  794.   Q_OBJECT
  795. public:
  796.   enum Type {
  797.       TypeVoid=0, TypeBool, TypeFunction, TypeNumber, TypeObject, TypeString
  798.   };
  799.   typedef QValueList<QPair<Type, QString> > ArgList;
  800.  
  801.   LiveConnectExtension( KParts::ReadOnlyPart *parent, const char *name = 0L );
  802.  
  803.   virtual ~LiveConnectExtension() {}
  804.   /**
  805.    * get a field value from objid, return true on success
  806.    */
  807.   virtual bool get( const unsigned long objid, const QString & field, Type & type, unsigned long & retobjid, QString & value );
  808.   /**
  809.    * put a field value in objid, return true on success
  810.    */
  811.   virtual bool put( const unsigned long objid, const QString & field, const QString & value );
  812.   /**
  813.    * calls a function of objid, return true on success
  814.    */
  815.   virtual bool call( const unsigned long objid, const QString & func, const QStringList & args, Type & type, unsigned long & retobjid, QString & value );
  816.   /**
  817.    * notifies the part that there is no reference anymore to objid
  818.    */
  819.   virtual void unregister( const unsigned long objid );
  820.  
  821.   static LiveConnectExtension *childObject( QObject *obj );
  822. signals:
  823.   /**
  824.    * notify an event from the part of object objid
  825.    */
  826.   virtual void partEvent( const unsigned long objid, const QString & event, const ArgList & args );
  827. };
  828.  
  829. }
  830.  
  831. #endif
  832.  
  833.